/* eslint-disable react/prop-types */
import { Modal } from "antd"

import { IUserInfo } from "@/api/member/types"
import { IMemberParams } from "@/api/risk/types"
import { useLocale } from "@/locales"

import { LabelMemberModal } from "./LabelMemberModal"
import { RebateStatusModal } from "./RebateStatusModal"
import { RiskControlLevelModal } from "./RiskControlLevelModal"
import { RiskControlNoteModal } from "./RiskControlNoteModal"

interface IMemberDetailModalProps {
	type: string
	handleCancel: () => void
	filterInfo: IMemberParams
	userInfo: IUserInfo
	handleGetUserInfo: () => Promise<void>
}

export const MemberDetailModal: React.FC<IMemberDetailModalProps> = ({
	type,
	handleCancel,
	filterInfo,
	userInfo,
	handleGetUserInfo
}) => {
	const { newFormat } = useLocale()
	const mess = `member.button_permissions.${type}`
	const title = newFormat(mess)

	return (
		<Modal footer={null} centered title={title} onCancel={handleCancel} open={type ? true : false}>
			<MemberDetailModalContent
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				type={type}
				userInfo={userInfo}
			/>
		</Modal>
	)
}

export const MemberDetailModalContent: React.FC<IMemberDetailModalProps> = ({
	type,
	handleCancel,
	filterInfo,
	userInfo,
	handleGetUserInfo
}) => {
	if (type === "riskControlNote")
		return (
			<RiskControlNoteModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "riskControlLevel")
		return (
			<RiskControlLevelModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "labelMember")
		return (
			<LabelMemberModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "rebateStatus")
		return (
			<RebateStatusModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	return <></>
}
